package com.lt.flashcard.view;

import java.util.List;

import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Page;

import com.lt.flashcard.Utility;
import com.lt.flashcard.model.entity.Cart;
import com.lt.flashcard.model.entity.Productcategory;
import com.lt.flashcard.model.service.EcommerceService;
import com.lt.flashcard.model.service.Repository;

public class StoreOverview {
	
	private List<Productcategory> categories = null;
	
	@Init
	public void init(@ContextParam(ContextType.PAGE) Page page) {
		Utility.addOgTag(page, "Sản phẩm của Blueup", "Các sản phẩm hiện có của Blueup", "");
	}

	public List<Productcategory> getCategories() {
		if(categories == null) {
			EcommerceService srv = Repository.getInstance().getEcommerceService();
			categories = srv.getParentProductCategories();
		}
		return categories;
	}

	public void setCategories(List<Productcategory> categories) {
		this.categories = categories;
	}
	
	/**
	 * Get the card
	 * @return
	 */
	public Cart getCart() {
		EcommerceService srv = Repository.getInstance().getEcommerceService();
		return srv.getCurrentCart();
	}
}
